package com.cr.api.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.cr.api.vo.CarouseVo;
import com.cr.business.domain.CrCarouselInfo;
import com.cr.business.service.ICrCarouselService;
import com.cr.common.core.controller.BaseController;
import com.cr.common.core.domain.AjaxResult;
import com.github.pagehelper.PageInfo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 问答Controller
 * 
 * @author G
 * @date 2021-09-14
 */
@Api(tags = "轮播图", value = "轮播图")
@RestController
@CrossOrigin
@RequestMapping("/api/carousel")
public class ApiCarouselController extends BaseController
{
    @Autowired
    private ICrCarouselService carouselService;
    /**
     * 轮播图列表
     */
    @ApiOperation("轮播图列表")
    @PostMapping("/getCarouselList")
    @ResponseBody
    public AjaxResult getCarouselList()
    {
        startPage();
        List<CrCarouselInfo> info = carouselService.selectCarouselList();
        List<CarouseVo> voList = new ArrayList<>();
        for(CrCarouselInfo u : info){
            CarouseVo vo = new CarouseVo();
            BeanUtils.copyProperties(u, vo);
            voList.add(vo);
        }
        return AjaxResult.success(new PageInfo<>(voList));
    }
}
